package csce315.group10.androidapp;
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;

import android.os.Parcel;
import android.os.Parcelable;


public class Event implements Parcelable{
	/* private instance variables */
	private String event_name;
	private String event_date;
	private String event_time;
	private String contact_name;
	private String contact_phone;
	private String staffer_covering;
	private String location;
	private String notes;
	public Event(@Attribute(name="name")String _event_name,@Element(name = "date",required=false)String _event_date,@Element(name = "time",required=false)String _event_time,
			@Element(name = "contact_name",required=false)String _contact_name,@Element(name = "contact_phone",required=false)String _contact_phone,@Element(name = "staffer_covering")String _staffer_covering,
			@Element(name = "location",required=false)String _location,@Element(name = "notes",required=false)String _notes){
		event_name = _event_name;
		event_date = _event_date;
		event_time = _event_time;
		contact_name = _contact_name;
		contact_phone = _contact_phone;
		staffer_covering = _staffer_covering;
		location = _location;
		notes = _notes;
	}
	/* constructor used by Parcelable */
	public Event(Parcel source){
        /*
         * Reconstruct from the Parcel
         */
        event_name = source.readString();
        event_date = source.readString();
        event_time = source.readString();
        contact_name = source.readString();
        contact_phone = source.readString();
        staffer_covering = source.readString();
        location = source.readString();
        notes = source.readString();
  }
	
	/* Accessors */
	@Attribute(name = "name")
	public String get_event_name(){
    	return event_name;
    }
	@Element(name = "date",required=false)
	public String get_event_date(){
		return event_date;
	}
	@Element(name = "time",required=false)
	public String get_event_time(){
		return event_time;
	}
	@Element(name = "contact_name",required=false)
	public String get_con_name(){
    	return contact_name;
    }
	@Element(name = "contact_phone",required=false)
	public String get_con_phone(){
    	return contact_phone;
    }
	@Element(name = "staffer_covering")
	public String get_staffer(){
    	return staffer_covering;
    }
	@Element(name = "location",required=false)
	public String get_location(){
    	return location;
    }
	@Element(name = "notes",required=false)
	public String get_notes(){
    	return notes;
    }
	public boolean hasLocation(){
		return location != null;
	}
	public int describeContents() {
		return hashCode();
	}
	/* used to serialize data to pass in an interface*/
	public void writeToParcel(Parcel dest, int flags) {
//		Log.v(TAG, "writeToParcel..."+ flags);
		dest.writeString(event_name);
		dest.writeString(event_date);
		dest.writeString(event_time);
	    dest.writeString(contact_name);
	    dest.writeString(contact_phone);
	    dest.writeString(staffer_covering);
	    dest.writeString(location);
	    dest.writeString(notes);
	}
	/* used to create an event object from Parcelable */
	public static final Parcelable.Creator CREATOR =
    	new Parcelable.Creator() {
            public Event createFromParcel(Parcel in) {
                return new Event(in);
            }
 
            public Event[] newArray(int size) {
                return new Event[size];
            }
        };
}